package com.yhy.dubbo.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yhy.domain.UserInfo;

import com.yhy.dubbo.api.UserInfoApi;
import com.yhy.mapper.UserInfoMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

@Service
public class UserInfoApiImpl implements UserInfoApi {

    @Autowired
    private UserInfoMapper userInfoMapper;

    @Override
    public void save(UserInfo userInfo) {
        userInfoMapper.insert(userInfo);
    }

    @Override
    public void update(UserInfo userInfo) {
        userInfoMapper.updateById(userInfo);
    }

    @Override
    public UserInfo findById(Long id) {
        return userInfoMapper.selectById(id);
    }

    @Override
    public IPage<UserInfo> findAll(Integer page, Integer pagesize) {
        Page<UserInfo> pages = new Page<>(page,pagesize);

        return userInfoMapper.selectPage(pages, null);
    }

    @Override
    public Integer count() {
        return userInfoMapper.selectCount(null);
    }
}
